package org.vshe.improve.hibernate.recipes.domain;

import java.io.Serializable;
import java.util.Set;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
import javax.persistence.Table;

import org.hibernate.annotations.CollectionOfElements;

@Entity

public class Orders implements Serializable {
	@Id
	@GeneratedValue(strategy=GenerationType.AUTO)
	@Column
	private Long id;
	
	@CollectionOfElements(targetElement=Contact.class, fetch=FetchType.EAGER)
	@JoinTable(name="order_contacts", joinColumns=@JoinColumn(name="order_id"))
	private Set contacts;
	
	
	public Orders() {
		super();
	}

	public Long getId() { 
		return id;
	}

	public void setId(Long id) {
		this.id = id;
	}

	
	
	public Set getContacts() {
		return contacts;
	}

	public void setContacts(Set contacts) {
		this.contacts = contacts;
	}

	
}
